﻿<!DOCTYPE html>
<html lang="en" class="no-js">
 <head> 
  <meta charset="UTF-8" /> 
  <meta name="viewport" content="width=device-width, initial-scale=1" /> 
  <title>炽热教育签到</title> 
  <link href="css/student_sign_css1.css" rel="stylesheet" /> 
  <script>

      document.documentElement.className = "js"; var supportsCssVars = function () { var e, t = document.createElement("style"); return t.innerHTML = "root: { --tmp-var: bold; }", document.head.appendChild(t), e = !!(window.CSS && window.CSS.supports && window.CSS.supports("font-weight", "var(--tmp-var)")), t.parentNode.removeChild(t), e }; supportsCssVars() || alert("Please view this demo in a modern browser that supports CSS Variables.");

		</script> 
 </head> 
 <body class="demo-1" onload="getWechatInfo()"> 
  <main> 
      <div class="section">

    <div class="title">炽热教育</div>
        <div class="curtain"></div>
    <canvas id="canvas"></canvas>

</div>
   <div class="grid" id="signView" > 
    <div class="grid__item theme-2" id="sign_in_bg"> 
     <button class="action">
      <svg class="icon icon--rewind">
       <use xlink:href="#icon-rewind"></use>
      </svg></button> 
     <button class="particles-button" onclick="qiandaoManager()" id="qiandao">签到</button> 
    </div> 
    <div class="grid__item theme-2" id="sign_out_bg"> 
     <button class="action">
      <svg class="icon icon--rewind">
       <use xlink:href="#icon-rewind"></use>
      </svg></button> 
     <button class="particles-button" onclick="qiantuiManager()" id="qiantui">签退</button> 
    </div> 
   </div> 
  </main>
     <script src="bg.js"></script>
     <script src="JavaScript1.js"></script>
     <link href="StyleSheet1.css" rel="stylesheet" />
     <link href="../chireh5/Sign/css/student_sign_css1.css" rel="stylesheet" />
     <script src="../chireh5/Sign/css/student_sign_js1.js"></script>
     <script src="../chireh5/Sign/css/student_sign_js2.js"></script>
     <script src="../chireh5/Sign/css/student_sign_js3.js"></script>
 
  <script src="../../backstage/lib/jquery/1.9.1/jquery.min.js"></script> 
  <script>
      function GetQueryString(name) {
          var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
          var r = window.location.search.substr(1).match(reg);//search,查询？后面的参数，并匹配正则
          if (r != null) return unescape(r[2]); return null;
      }

      // 获取微信信息
      function getWechatInfo() {
          var code = GetQueryString('code');

          var args = $.param({
              "code": code
          })
          $.ajax({
              url: '../../ChireInter/Wechat/wechat_auth.ashx',
              data: args,
              type: 'post',
              dataType: 'json',
              success: function (res) {
                  if (res.errCode == 200) {
                      getAuthManager(code);
                  } else {

                  }
              },
              error: function (err) {

              }
          })

      }
      /*获取是否有权限*/
      function getAuthManager() {
          // 1. 获取code
          var code = GetQueryString("code");

          $.ajax({
              url: '../../ChireInter/Identity/Identity_HasAuthMember.ashx',
              data: { code: code },
              type: 'post',
              dataType: 'json',
              success: function (res) {

                  if (res.errCode == 200) {

                      if (res.data.hasMember == 1) {
                          document.getElementById("signView").style.display = "";//显
                          getSignStatus(code);

                      } else if (res.data.hasMember == 0) {

                          window.location.href = "../404/404.html";
                      }
                  } else {

                  }
              },
              error: function (err) {
                  alert('提交失败' + err);
              }
          })
      }
      // 获取签到状态信息
      function getSignStatus(code) {
          var args = $.param({
              "code": code
          })
          $.ajax({
              url: '../../ChireInter/Sign/Sign_Status.ashx',
              data: args,
              type: 'post',
              dataType: 'json',
              success: function (res) {
                  if (res.errCode == 200) {
                      if (res.data.sign_in.date == "" || res.data.sign_in.date == null) {

                          //var html = "";
                          //html += "";
                          //html += "";

                          //var inContent = $('#sign_in_bg')
                          //inContent.html(html);
                      } else {
                          var html = "";
                          html += "<p>" + "已签到" + res.data.sign_in.time + "</p>";

                          var inContent = $('#sign_in_bg')
                          inContent.html(html);

                      }

                      if (res.data.sign_out.date == "" || res.data.sign_out.date == null) {

                          //var html = "";

                          //var outContent = $('#sign_out_bg')
                          //outContent.html(html);

                      } else {

                          var html = "";
                          html += "<p>" + "已签退" + res.data.sign_out.time + "</p>";
                          var outContent = $('#sign_out_bg')
                          outContent.html(html);
                      }

                  } else {

                  }
              },
              error: function (err) {

              }
          })

      }
      // 进行签到
      function qiandaoManager() {
          var code = GetQueryString('code');

          var args = $.param({
              "code": code,
              "signType": "1"
          })
          $.ajax({
              url: '../../ChireInter/Sign/Sign_Login.ashx',
              data: args,
              type: 'post',
              dataType: 'json',
              success: function (res) {
                  if (res.errCode == 200) {
                      var html = "";
                      html += "<p>" + "已签到" + res.data.time + "</p>";

                      var inContent = $('#sign_in_bg')
                      inContent.html(html);

                  } else {
                      alert(res.errMsg);
                  }
              },
              error: function (err) {

              }
          })
      }
      // 进行签退
      function qiantuiManager() {
          var code = GetQueryString('code');

          var args = $.param({
              "code": code,
              "signType": "2"

          })
          $.ajax({
              url: '../../ChireInter/Sign/Sign_Login.ashx',
              data: args,
              type: 'post',
              dataType: 'json',
              success: function (res) {
                  if (res.errCode == 200) {

                      var html = "";
                      html += "<p>" + "已签退" + res.data.time + "</p>";

                      var outContent = $('#sign_out_bg')
                      outContent.html(html);
                  } else {

                  }
              },
              error: function (err) {

              }
          })
      }
        </script>   
 </body>
</html>